<template>
    <a-drawer
        width="50%"
        :title="in_tif_data?.path"
        placement="left"
        :visible="modal_show"
        :maskClosable="false"
        :closable="false"
        :bodyStyle="{ padding: '0px' }"
        :zIndex="1001"
        >
        <template #extra>
        <a-tooltip  placement="bottom">
            <template #title>保存</template>
            <a-button @click="OnSave" style="margin: 0 auto;margin-right: 10px;">
                <template #icon><check-outlined /></template>
            </a-button>
        </a-tooltip>
          <a-tooltip  placement="bottom">
              <template #title>关闭</template>
              <a-button @click="onClose" style="margin: 0 auto;margin-right: 10px;">
                <template #icon>
                    <close-outlined />
                </template>
              </a-button>
            </a-tooltip>
        </template>
        <div style="padding: 5px;">
            <a-tabs v-model:activeKey="tabs_activeKey" :default-active-key="tabs_activeKey" style="width: 100%;" @change="tab_change">
                <a-tab-pane :key="1">
                    <template #tab><span>配置信息</span></template>
                    <a-divider>选择载荷</a-divider>
                    <a-row  style="width: 100%;" >
                        <a-col :span="12" style="width: 100%;">
                            <a-form :model="nuform" name="basic" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" autocomplete="off" class="smale-form">
                                <a-form-item label="选择载荷">
                                    <a-col :span="22" class="smale-select" >
                                        <a-select 
                                        v-model:value="in_tif_prop_data.sensor_name" 
                                        style="width: 150px;" 
                                        :options="$store.state.task?.sensors"
                                        dropdownClassName="smale-select-span"
                                        size="small" 
                                        :field-names="{ label: 'name', value: 'name' }"
                                        @change="sensor_change"
                                        >
                                        </a-select>
                                    </a-col>
                                </a-form-item>
                            </a-form>
                        </a-col>
                    </a-row>
                    <div v-if="sensor_index>=0">
                        <a-divider>载荷信息</a-divider>
                        <a-row  style="width: 100%;" >
                            <a-col :span="12" style="width: 100%;">
                                <a-form :model="nuform" name="basic" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" autocomplete="off" class="smale-form">
                                    <a-form-item label="载荷类型">
                                        <a-col :span="22" class="smale-select" >
                                            <a-select 
                                            v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.attribute" 
                                            style="width: 150px;" 
                                            :options="$store.state.sensor_type"
                                            dropdownClassName="smale-select-span"
                                            size="small" 
                                            class="smale-select"
                                            :field-names="{ label: 'name', value: 'name' }">
                                            
                                            </a-select>
                                        </a-col>
                                    </a-form-item>
                                </a-form>
                            </a-col>
                            <a-col :span="12" style="width: 100%;">
                                <a-form :model="nuform" name="basic" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" autocomplete="off" class="smale-form">
                                    <a-form-item label="主距">
                                        <a-col :span="22">
                                            <a-input v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.f" />
                                        </a-col>
                                    </a-form-item>
                                </a-form>
                            </a-col>
                        </a-row>
                        <a-row  style="width: 100%;" >
                            <a-col :span="12" style="width: 100%;">
                                <a-row  style="width: 100%;" >
                                    <a-col :span="8" style="width: 100%;">
                                        <a-form :model="nuform" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" class="smale-form">
                                            <a-form-item label="CCD数量"></a-form-item>
                                            <a-form-item label="CCD阵列"></a-form-item>
                                        </a-form>
                                    </a-col>
                                    <a-col :span="8" style="width: 100%;">
                                        <a-form :model="nuform" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" class="smale-form">
                                            <a-form-item label="垂轨">
                                                <a-col :span="22">
                                                    <a-input v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.NumofCCDs.x" />
                                                </a-col>
                                            </a-form-item>
                                            <a-form-item label="宽">
                                                <a-col :span="22">
                                                    <a-input v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.CCDInfo.WidofCCD" />
                                                </a-col>
                                            </a-form-item>
                                        </a-form>
                                    </a-col>
                                    <a-col :span="8" style="width: 100%;">
                                        <a-form :model="nuform" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" class="smale-form">
                                            <a-form-item label="沿轨">
                                                <a-col :span="22">
                                                    <a-input v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.NumofCCDs.y" />
                                                </a-col>
                                            </a-form-item>
                                            <a-form-item label="高">
                                                <a-col :span="22">
                                                    <a-input v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.CCDInfo.HeiofCCD" />
                                                </a-col>
                                            </a-form-item>
                                        </a-form>
                                    </a-col>
                                </a-row>
                            </a-col>
                            <a-col :span="12" style="width: 100%;">
                                <a-row  style="width: 100%;" >
                                    <a-col :span="8" style="width: 100%;">
                                        <a-form :model="nuform" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" class="smale-form">
                                            <a-form-item label="探元大小"></a-form-item>
                                            <a-form-item label="左上角点(像素)"></a-form-item>
                                        </a-form>
                                    </a-col>
                                    <a-col :span="8" style="width: 100%;">
                                        <a-form :model="nuform" name="basic" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" autocomplete="off" class="smale-form">
                                            <a-form-item label="x">
                                                <a-col :span="22">
                                                    <a-input v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.CCDInfo.CCDSize.x" />
                                                </a-col>
                                            </a-form-item>
                                            <a-form-item label="x">
                                                <a-col :span="22">
                                                    <a-input v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.CCDInfo.LeftUpCoordInPixels.x" />
                                                </a-col>
                                            </a-form-item>
                                        </a-form>
                                    </a-col>
                                    <a-col :span="8" style="width: 100%;">
                                        <a-form :model="nuform" name="basic" :label-col="{ span: 5 }" :wrapper-col="{ span: 19 }" autocomplete="off" class="smale-form">
                                            <a-form-item label="y">
                                                <a-col :span="22">
                                                    <a-input v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.CCDInfo.CCDSize.y" />
                                                </a-col>
                                            </a-form-item>
                                            <a-form-item label="y">
                                                <a-col :span="22">
                                                    <a-input v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.CCDInfo.LeftUpCoordInPixels.y" />
                                                </a-col>
                                            </a-form-item>
                                        </a-form>
                                    </a-col>
                                </a-row>
                            </a-col>
                        </a-row>
                        <a-divider>各片CCD或CMOS左上角点相对于第一片左上角点的垂轨关系(用英文逗号隔开):</a-divider>
                        <a-row  style="width: 100%;" >
                            <a-col :span="24" style="width: 100%;">
                                <a-form :model="nuform" name="basic" :label-col="{ span: 3 }" :wrapper-col="{ span: 21 }" autocomplete="off" class="smale-form">
                                    <a-form-item label="x">
                                        <a-col :span="22">
                                            <a-input v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.CCDInfo.relativePos.x" />
                                        </a-col>
                                    </a-form-item>
                                    <a-form-item label="y">
                                        <a-col :span="22">
                                            <a-input v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.CCDInfo.relativePos.y" />
                                        </a-col>
                                    </a-form-item>
                                </a-form>
                            </a-col>
                        </a-row>
                        <a-divider>安装矩阵(用英文逗号隔开):</a-divider>
                        <a-row  style="width: 100%;" >
                            <a-col :span="24" style="width: 100%;">
                                <a-form :model="nuform" name="basic" :label-col="{ span: 3 }" :wrapper-col="{ span: 21 }" autocomplete="off" class="smale-form">
                                    <a-form-item label="矩阵:">
                                        <a-col :span="22">
                                            <a-textarea v-model:value="$store.state.task.sensors[sensor_index].sensorInfo.installMatrix" />
                                        </a-col>
                                    </a-form-item>
                                </a-form>
                            </a-col>
                        </a-row>
                    </div>
                </a-tab-pane>
                <a-tab-pane :key="2" v-if="sensor_index>=0">
                    <template #tab><span>模型信息</span></template>
                    <a-divider>基础信息</a-divider>
                    <a-row  style="width: 100%;" >
                        <a-col :span="8" style="width: 100%;">
                            <a-form :model="nuform" name="basic" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" autocomplete="off" class="smale-form">
                                <a-form-item label="载荷类型">
                                    <a-col :span="22" class="smale-select" >
                                        <a-select 
                                        v-model:value="in_tif_prop_data.sensor_attribute" 
                                        style="width: 150px;" 
                                        :options="$store.state.sensor_type"
                                        dropdownClassName="smale-select-span"
                                        size="small" 
                                        :field-names="{ label: 'name', value: 'name' }"
                                        >
                                        </a-select>
                                    </a-col>
                                </a-form-item>
                            </a-form>
                        </a-col>
                        <a-col :span="8" style="width: 100%;">
                            <a-form :model="nuform" name="basic" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" autocomplete="off" class="smale-form">
                                <a-form-item label="时间系统">
                                    <a-col :span="22" class="smale-select" >
                                        <a-select 
                                        v-model:value="in_tif_prop_data.modal.TimeSys" 
                                        style="width: 150px;" 
                                        :options="$store.state.time_type"
                                        dropdownClassName="smale-select-span"
                                        size="small" 
                                        :field-names="{ label: 'name', value: 'name' }">
                                        </a-select>
                                    </a-col>
                                </a-form-item>
                            </a-form>
                        </a-col>
                        <a-col :span="8" style="width: 100%;">
                            <a-form :model="nuform" name="basic" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" autocomplete="off" class="smale-form">
                                <a-form-item label="姿态系统">
                                    <a-col :span="22" class="smale-select" >
                                        <a-select 
                                        v-model:value="in_tif_prop_data.modal.AttSys" 
                                        style="width: 150px;" 
                                        :options="$store.state.zitai_type"
                                        dropdownClassName="smale-select-span"
                                        size="small" 
                                        :field-names="{ label: 'name', value: 'name' }">
                                        </a-select>
                                    </a-col>
                                </a-form-item>
                            </a-form>
                        </a-col>
                    </a-row>
                    <a-row  style="width: 100%;" >
                        <a-col :span="24" style="width: 100%;">
                            <a-form :model="nuform" name="basic" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" autocomplete="off" class="smale-form">
                                <a-form-item label="载荷信息文件">
                                    <a-col :span="20">
                                        <a-input v-model:value="$store.state.task.sensors[sensor_index].path" :disabled="true"/>
                                    </a-col>
                                    <a-col :span="1"></a-col>
                                    <a-col :span="3">
                                    </a-col>
                                </a-form-item>
                                <a-form-item label="轨道文件">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.modal.GeoAuxFiles.Ep" />
                                    </a-col>
                                    <a-col :span="1"></a-col>
                                    <a-col :span="3">
                                        <a-button type="primary" size="small" @click="select_file('eph')">选择</a-button>
                                    </a-col>
                                </a-form-item>
                                <a-form-item label="姿态文件">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.modal.GeoAuxFiles.Att"/>
                                    </a-col>
                                    <a-col :span="1"></a-col>
                                    <a-col :span="3">
                                        <a-button type="primary" size="small" @click="select_file('att')">选择</a-button>
                                    </a-col>
                                </a-form-item>
                                <a-form-item label="行时文件">
                                    <a-col :span="20">
                                        <a-input v-model:value="camTime_labels" :disabled="true"/>
                                    </a-col>
                                    <a-col :span="1"></a-col>
                                    <a-col :span="3">
                                        <a-button type="primary" size="small" @click="select_file('it')">选择</a-button>
                                    </a-col>
                                </a-form-item>
                                <a-form-item label="编目信息文件">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.modal.GeoAuxFiles.CatalogInfo"/>
                                    </a-col>
                                    <a-col :span="1"></a-col>
                                    <a-col :span="3">
                                        <a-button type="primary" size="small" @click="select_file('txt')">选择</a-button>
                                    </a-col> 
                                </a-form-item>
                                <a-form-item label="摆静角度文件">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.modal.GeoAuxFiles.SwingAngularVel" :disabled="true"/>
                                    </a-col>
                                    <a-col :span="1"></a-col>
                                    <a-col :span="3">
                                        <a-button type="primary" size="small" @click="select_file('AAAA')" :disabled="true">选择</a-button>
                                    </a-col>
                                </a-form-item>
                            </a-form>
                        </a-col>
                    </a-row>
                    <a-divider>定标信息</a-divider>
                    <a-row  style="width: 100%;" >
                        <a-col :span="24" style="width: 100%;">
                            <a-form :model="nuform" name="basic" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" autocomplete="off" class="smale-form">
                                <a-form-item label="偏置矩阵文件">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.modal.GeoCalibrationFiles.OffsetAngle"/>
                                    </a-col>
                                    <a-col :span="1"></a-col>
                                    <a-col :span="3">
                                        <a-button type="primary" size="small" @click="select_file('ext')">选择</a-button>
                                    </a-col>
                                </a-form-item>
                                <a-form-item label="内方位原始文件">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.modal.GeoCalibrationFiles.InnerMdl" />
                                    </a-col>
                                    <a-col :span="1"></a-col>
                                    <a-col :span="3">
                                        <a-button type="primary" size="small" @click="select_file('int')">选择</a-button>
                                    </a-col>
                                </a-form-item>
                                <a-form-item label="内方位原始类型">
                                    <a-col :span="8" class="smale-select" >
                                        <a-select 
                                        v-model:value="in_tif_prop_data.modal.GeoCalibrationFiles.InnerMdlType" 
                                        style="width: 150px;" 
                                        :options="$store.state.InnerMdl_type"
                                        dropdownClassName="smale-select-span"
                                        size="small" 
                                        :field-names="{ label: 'name', value: 'name' }"
                                        >
                                        </a-select>
                                    </a-col>
                                </a-form-item>
                            </a-form>
                        </a-col>
                    </a-row>
                    <a-divider>模型参数</a-divider>
                    <a-row  style="width: 100%;" >
                        <a-col :span="12" style="width: 100%;">
                            <a-row  style="width: 100%;" >
                                <a-form :model="nuform" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" class="smale-form">
                                    <a-form-item label="轨道内插模型">
                                        <a-col :span="24" class="smale-select" >
                                            <a-select 
                                            v-model:value="in_tif_prop_data.modal.GeoModelParams.OrbitInterpolation" 
                                            style="width: 150px;" 
                                            :options="$store.state.OrbitInterpolation_modal"
                                            dropdownClassName="smale-select-span"
                                            size="small" 
                                            :field-names="{ label: 'name', value: 'name' }"
                                            >
                                            </a-select>
                                        </a-col>
                                    </a-form-item>
                                    <a-form-item label="姿态内插模型">
                                        <a-col :span="24" class="smale-select" >
                                            <a-select 
                                            v-model:value="in_tif_prop_data.modal.GeoModelParams.AttInterpolation" 
                                            style="width: 150px;" 
                                            :options="$store.state.AttInterpolation_modal"
                                            dropdownClassName="smale-select-span"
                                            size="small" 
                                            :field-names="{ label: 'name', value: 'name' }"
                                            >
                                            </a-select>
                                        </a-col>
                                    </a-form-item>
                                    <a-form-item label="时间内插模型">
                                        <a-col :span="24" class="smale-select" >
                                            <a-select 
                                            v-model:value="in_tif_prop_data.modal.GeoModelParams.TimeInterpolation" 
                                            style="width: 150px;" 
                                            :options="$store.state.TimeInterpolation_modal"
                                            dropdownClassName="smale-select-span"
                                            size="small" 
                                            :field-names="{ label: 'name', value: 'name' }"
                                            >
                                            </a-select>
                                        </a-col>
                                    </a-form-item>
                                </a-form>
                            </a-row>
                        </a-col>
                        <a-col :span="12" style="width: 100%;">
                            <a-row  style="width: 100%;" >
                                <a-form :model="nuform" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" class="smale-form">
                                    <a-form-item label="轨道模型阶数">
                                        <a-col :span="22">
                                            <a-input v-model:value="in_tif_prop_data.modal.GeoModelParams.OrbitOrder" />
                                        </a-col>
                                    </a-form-item>
                                    <a-form-item label="姿态模型阶数">
                                        <a-col :span="22">
                                            <a-input v-model:value="in_tif_prop_data.modal.GeoModelParams.AttOrder" />
                                        </a-col>
                                    </a-form-item>
                                    <a-form-item label="时间内插模型">
                                        <a-col :span="24" class="smale-select" >
                                            <a-select 
                                            v-model:value="in_tif_prop_data.modal.GeoModelParams.LookAngleCalc" 
                                            style="width: 150px;" 
                                            :options="$store.state.LookAngleCalc_modal"
                                            dropdownClassName="smale-select-span"
                                            size="small" 
                                            :field-names="{ label: 'name', value: 'name' }"
                                            >
                                            </a-select>
                                        </a-col> 
                                    </a-form-item>
                                </a-form>
                            </a-row>
                        </a-col>
                    </a-row>
                    <a-row  style="width: 100%;" >
                        <a-col :span="8" style="width: 100%;">
                            <a-row  style="width: 100%;" >
                                <a-form :model="nuform" name="basic" :label-col="{ span: 12 }" :wrapper-col="{ span: 12 }" autocomplete="off" class="smale-form">
                                    <a-form-item label="行时外扩数量">
                                        <a-col :span="22">
                                            <a-input v-model:value="in_tif_prop_data.modal.GeoModelParams.ExtentLines" />
                                        </a-col>
                                    </a-form-item>
                                </a-form>
                            </a-row>
                        </a-col>
                        <a-col :span="8" style="width: 100%;">
                            <a-row  style="width: 100%;" >
                                <a-form :model="nuform" name="basic" :label-col="{ span: 12 }" :wrapper-col="{ span: 12 }" autocomplete="off" class="smale-form">
                                    <a-form-item label="轨道外扩时间">
                                        <a-col :span="22">
                                            <a-input v-model:value="in_tif_prop_data.modal.GeoModelParams.ExtentEpTime" />
                                        </a-col>
                                    </a-form-item>
                                </a-form>
                            </a-row>
                        </a-col>
                        <a-col :span="8" style="width: 100%;">
                            <a-row  style="width: 100%;" >
                                <a-form :model="nuform" name="basic" :label-col="{ span: 12 }" :wrapper-col="{ span: 12 }" autocomplete="off" class="smale-form">
                                    <a-form-item label="姿态外扩时间">
                                        <a-col :span="22">
                                            <a-input v-model:value="in_tif_prop_data.modal.GeoModelParams.ExtentAttTime" />
                                        </a-col>
                                    </a-form-item>
                                </a-form>
                            </a-row>
                        </a-col>
                    </a-row>
                </a-tab-pane>
                <a-tab-pane :key="3" v-if="sensor_index>=0">
                    <template #tab><span>控制点信息</span></template>
                    <a-divider>基础信息</a-divider>
                    <a-row  style="width: 100%;" >
                        <a-col :span="24" style="width: 100%;">
                            <a-form :model="nuform" name="basic" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" autocomplete="off" class="smale-form">
                                <a-form-item label="载荷类型">
                                    <a-col :span="22" class="smale-select" >
                                        <a-select 
                                        v-model:value="in_tif_prop_data.sensor_attribute" 
                                        style="width: 150px;" 
                                        :options="$store.state.sensor_type"
                                        dropdownClassName="smale-select-span"
                                        size="small" 
                                        :field-names="{ label: 'name', value: 'name' }"
                                        >
                                        </a-select>
                                    </a-col>
                                </a-form-item>
                                <a-form-item label="DOM">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.ctl_Dom" />
                                    </a-col>
                                    <a-col :span="1"></a-col>
                                    <a-col :span="3">
                                        <a-button type="primary" size="small" @click="select_dir('dom')">选择</a-button>
                                    </a-col>
                                </a-form-item>
                                <a-form-item label="DEM">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.ctl_Dem"/>
                                    </a-col>
                                    <a-col :span="1"></a-col>
                                    <a-col :span="3">
                                        <a-button type="primary" size="small" @click="select_dir('dem')">选择</a-button>
                                    </a-col>
                                </a-form-item>
                            </a-form>
                        </a-col>
                    </a-row>
                    <a-divider>仿真参数</a-divider>
                    <a-row  style="width: 100%;" >
                        <a-col :span="6" style="width: 100%;">
                            <a-form 
                            :model="nuform" 
                            name="basic" 
                            :label-col="{ span: 10 }" 
                            :wrapper-col="{ span: 14 }" 
                            autocomplete="off" 
                            class="smale-form"
                            >
                                <a-form-item label="高程迭代限差">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.ctl.tolerance_h" />
                                    </a-col>
                                </a-form-item>
                            </a-form>
                        </a-col>
                        <a-col :span="6" style="width: 100%;">
                            <a-form 
                            :model="nuform" 
                            name="basic" 
                            :label-col="{ span: 10 }" 
                            :wrapper-col="{ span: 14 }" 
                            autocomplete="off" 
                            class="smale-form"
                            >
                                <a-form-item label="仿真分块行">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.ctl.simulateParam.blkLines" />
                                    </a-col>
                                </a-form-item>
                            </a-form>
                        </a-col>
                        <a-col :span="6" style="width: 100%;">
                            <a-form 
                            :model="nuform" 
                            name="basic" 
                            :label-col="{ span: 10 }" 
                            :wrapper-col="{ span: 14 }" 
                            autocomplete="off" 
                            class="smale-form"
                            >
                                <a-form-item label="仿真分块列">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.ctl.simulateParam.blkSamples" />
                                    </a-col>
                                </a-form-item>
                            </a-form>
                        </a-col>
                    </a-row>
                    <a-row  style="width: 100%;" >
                        <a-table 
                        :data-source="in_tif_prop_data.ctl.ctl_simulate_data" 
                        :columns="ctl_simulate_columns"
                        class="task-table" 
                        size="small" 
                        :showHeader="true" 
                        tableLayout="fixed"
                        :pagination="ctl_simulate_pagination"
                        bordered rowKey="ccd"
                        >
                        <template #bodyCell="{ text, record, index, column }">
                            <template  v-if="column.dataIndex === 'startX'">
                                <a-input v-model:value="record.startX"/>
                            </template>
                            <template  v-if="column.dataIndex === 'startY'">
                                <a-input v-model:value="record.startY"/>
                            </template>
                            <template  v-if="column.dataIndex === 'width'">
                                <a-input v-model:value="record.width"/>
                            </template>
                            <template  v-if="column.dataIndex === 'height'">
                                <a-input v-model:value="record.height"/>
                            </template>
                            <template  v-if="column.dataIndex === 'iBand'">
                                <a-select 
                                    v-model:value="record.iBand" 
                                    style="width: 60px;" 
                                    :options="in_tif_bands"
                                    dropdownClassName="smale-select-span"
                                    size="small" 
                                    :field-names="{ label: 'name', value: 'name' }"
                                    >
                                    </a-select>
                            </template>
                            <template  v-if="column.dataIndex === 'isSimulate'">
                                <div class="smale-select">
                                    <a-select 
                                    v-model:value="record.isSimulate" 
                                    style="width: 100%;" 
                                    :options="$store.state.yes_not"
                                    dropdownClassName="smale-select-span"
                                    size="small" 
                                    :field-names="{ label: 'label', value: 'value' }"
                                    >
                                    </a-select>
                                </div>
                            </template>
                        </template>
                        </a-table>
                    </a-row>
                </a-tab-pane>
                <!-- nuform -->
                <a-tab-pane :key="4" v-if="sensor_index>=0">
                    <template #tab><span>连接点信息</span></template>
                    <a-divider>基础信息</a-divider>
                    <a-row  style="width: 100%;" >
                        <a-col :span="24" style="width: 100%;">
                            <a-form :model="nuform" name="basic" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" autocomplete="off" class="smale-form">
                                <a-form-item label="载荷类型">
                                    <a-col :span="22" class="smale-select" >
                                        <a-input v-model:value="in_tif_prop_data.sensor_attribute" :disabled="true"/>
                                    </a-col>
                                </a-form-item>
                                <a-form-item label="起始行">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.tile.matchParam.startLine"/>
                                    </a-col>
                                </a-form-item>
                                <a-form-item label="终止行">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.tile.matchParam.endLine"/>
                                    </a-col>
                                    <a-col :span="1"></a-col>
                                </a-form-item>
                            </a-form>
                        </a-col>
                    </a-row>
                </a-tab-pane>
                <a-tab-pane :key="5" v-if="sensor_index>=0">
                    <template #tab><span>定标序号</span></template>
                    <a-divider>基础信息</a-divider>
                    <a-row  style="width: 100%;" >
                        <a-col :span="24" style="width: 100%;">
                            <a-form :model="nuform" name="basic" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" autocomplete="off" class="smale-form">
                                <a-form-item label="外定标索引">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.ei"/>
                                    </a-col>
                                </a-form-item>
                                <a-form-item label="内定标索引">
                                    <a-col :span="20">
                                        <a-input v-model:value="in_tif_prop_data.ii"/>
                                    </a-col>
                                    <a-col :span="1"></a-col>
                                </a-form-item>
                            </a-form>
                        </a-col>
                    </a-row>
                </a-tab-pane>
            </a-tabs>
        </div>
    </a-drawer>
</template>
<script>
import { defineAsyncComponent,watch, reactive } from 'vue'
export default {
    data() {
        return {
            modal_show: false,
            nuform:{},//无用 model form
            in_tif_index:-1,
            in_tif_data:{},
            in_tif_bands:[], //DOM波段索引
            in_tif_prop_data:{},
            sensor_index:-1,//index in this.$store.state.task?.sensors
            tabs_activeKey:1,
            camTime_labels:"",
            ctl_simulate_columns: [
                {
                    title: 'CCD',
                    dataIndex: 'ccd',
                    align: 'center',
                    width: '100',
                },
                {
                    title: '起始行',
                    dataIndex: 'startX',
                    align: 'center',
                    width: '100',
                },
                {
                    title: '起始列',
                    dataIndex: 'startY',
                    align: 'center',
                    width: '100',
                },
                {
                    title: '宽度',
                    dataIndex: 'width',
                    align: 'center',
                    width: '100',
                },
                {
                    title: '高度',
                    dataIndex: 'height',
                    align: 'center',
                    width: '100',
                },
                {
                    title: 'DOM波段号',
                    dataIndex: 'iBand',
                    align: 'center',
                    width: '100',
                },
                {
                    title: '是否仿真',
                    dataIndex: 'isSimulate',
                    align: 'center',
                    width: '100',
                },
            ],
            ctl_simulate_pagination: {
                current: 1,
                size: 'small',
                pageSize: 10,
                total: 0,
                showTotal: (total, range) => {
                    return `共 ${total},${range[0]}/${range[1]}`
                },
            },
            //mitt
            mitt_tif_cfg_id:"",
            mitt_tif_cfg_back_id:"",
            mitt_modal_select_server_dir_back_id:"",
        };
    },
    beforeUnmount() {
        this.$mitt.off('tif_cfg',this.mitt_tif_cfg_id);
        this.$mitt.off('modal_select_server_dir_back',this.mitt_modal_select_server_dir_back_id);
        console.log("beforeUnmount",this.mitt_tif_cfg_id)
    },
    mounted() {
        this.mitt_tif_cfg_id=this.$mitt.on('tif_cfg',async (uid,index)  => {
            this.mitt_tif_cfg_back_id=uid
            this.init_data(index);
            this.modal_show = true;
        },this?.$?.uid);
        this.mitt_modal_select_server_dir_back_id=this.$mitt.on('modal_select_server_dir_back', (type_select_dir) => {
            if (type_select_dir.type == 'eph') {
                this.in_tif_prop_data.modal.GeoAuxFiles.Ep = type_select_dir.val;
            }
            else if (type_select_dir.type == 'att') {
                this.in_tif_prop_data.modal.GeoAuxFiles.Att= type_select_dir.val
            }
            //此处需要修改
            else if (type_select_dir.type == 'it') {
                let sensorInfo=this.$store.state.task.sensors[this.sensor_index].sensorInfo
                let NumofCCDsX=sensorInfo?.NumofCCDs?.x-0 //CCD 数量 垂轨
                let NumofCCDsy=sensorInfo?.NumofCCDs?.y-0 //CCD 数量 沿轨
                let ccd_count=NumofCCDsX*NumofCCDsy
                let its=type_select_dir.val
                if(its?.length==ccd_count){
                    this.camTime_labels=its?.join(",")
                    this.in_tif_prop_data.modal.GeoAuxFiles.camTime=its
                }
                else if(its?.length==1){
                    let new_its=[]
                    for (let i = 0; i < ccd_count; i++) {
                        new_its.push(its[0])
                    }
                    this.camTime_labels=new_its?.join(",")
                    this.in_tif_prop_data.modal.GeoAuxFiles.camTime=new_its
                }
            }
            else if (type_select_dir.type == 'txt') {
                this.in_tif_prop_data.modal.GeoAuxFiles.CatalogInfo = type_select_dir.val
            }
            else if (type_select_dir.type == 'ext') {
                this.in_tif_prop_data.modal.GeoCalibrationFiles.OffsetAngle = type_select_dir.val
            }
            else if (type_select_dir.type == 'int') {
                this.in_tif_prop_data.modal.GeoCalibrationFiles.InnerMdl = type_select_dir.val
            }
            else if (type_select_dir.type == 'dom') {
                this.in_tif_prop_data.ctl_Dom = type_select_dir.val
            }
            else if (type_select_dir.type == 'dem') {
                this.in_tif_prop_data.ctl_Dem = type_select_dir.val
            }
        },this?.$?.uid);
        console.log("tif_cfg mounted")
    },
    methods: {
        init_data(index){
            this.sensor_index=-1;
            this.tabs_activeKey=1
            this.in_tif_index=index
            if(this.$store.state.task?.tifs?.length>0){
                this.in_tif_data=this.$store.state.task?.tifs[index]
                //set in_tif_bands
                {
                    this.in_tif_bands=[]
                    for (let i = 0; i < this.in_tif_data?.b; i++) {
                        this.in_tif_bands.push(
                            {
                                name:i,
                                value:i
                            }
                        )
                    }
                }
                //set or init in_tif_prop_data
                if(this.in_tif_data?.prop){
                    this.in_tif_prop_data=this.in_tif_data?.prop
                    if(this.in_tif_prop_data?.modal?.GeoAuxFiles?.camTime){
                        let camTime=this.in_tif_prop_data.modal?.GeoAuxFiles?.camTime
                        let its=[]
                        for (let i = 0; i < camTime?.length; i++) {
                            let one_camTime = camTime[i];
                            its.push(one_camTime)
                        }
                        this.camTime_labels=its?.join(",") 
                    }
                }
                else{
                    this.camTime_labels="";
                    this.in_tif_prop_data={
                        sensor_name:"",
                        sensor_attribute:"",
                        ei:this.in_tif_index,
                        ii:this.in_tif_index,
                        modal:{
                            TimeSys:"GMT",
                            AttSys:"J2000",
                            GeoAuxFiles:{
                                Ep:"",
                                Att:"",
                                camTime:[],
                                CatalogInfo:"",
                                SwingAngularVel:"",
                            },
                            GeoCalibrationFiles:{
                                OffsetAngle:"",
                                InnerMdl:"",
                                InnerMdlType:this.$store.state?.sets?.modal_msg?.model_innerMdlType,
                            },
                            GeoModelParams:JSON.parse(JSON.stringify(this.$store.state?.sets?.modal_parmar)),
                        },
                        ctl_Dom:"",
                        ctl_Dem:"",
                        ctl:{
                            nFrame:0,
                            tolerance_h:this.$store.state?.sets?.modal_ctr?.tolerance_h,
                            simulateParam:{
                                blkSamples:this.$store.state?.sets?.modal_ctr?.blkSamples,
                                blkLines:this.$store.state?.sets?.modal_ctr?.blkLines,
                            },
                            ctl_simulate_data:[] //ccd table
                        },
                        tile:{
                            matchParam:{
                                startLine:0,
                                endLine:this.in_tif_data?.row,
                            },
                            
                        },
                    }
                    console.log(this.in_tif_prop_data)
                }
                if(this.in_tif_prop_data?.sensor_name){
                    this.sensor_change(this.in_tif_prop_data?.sensor_name)
                }
            }
            else{
                console("no tif data")
            }
        },
        sensor_change(value){
            let find_sersor_index=this.$store.state.task.sensors?.findIndex((val)=>{
                return val?.name==value
            })
            if(find_sersor_index>=0){
                this.sensor_index=find_sersor_index
                this.in_tif_prop_data.sensor_attribute=this.$store.state.task.sensors[this.sensor_index]?.sensorInfo?.attribute

                let sensorInfo=this.$store.state.task.sensors[this.sensor_index].sensorInfo
                let NumofCCDsX=sensorInfo?.NumofCCDs?.x-0 //CCD 数量 垂轨
                let NumofCCDsy=sensorInfo?.NumofCCDs?.y-0 //CCD 数量 沿轨
                let WidofCCD  =sensorInfo?.CCDInfo?.WidofCCD//CCD阵列 宽
                let HeiofCCD  =sensorInfo?.CCDInfo?.HeiofCCD//CCD阵列 高
                //判断线阵和面阵的参数 与影像的高宽是否一致
                let attribute=this.in_tif_prop_data.sensor_attribute
                //线阵+线阵摆扫
                if(attribute=="Optical_Linear" ||attribute=="Linear_Swing" ){
                    if(NumofCCDsy!=1){
                        this.$message.warning("线阵模式下,沿轨通常设置为1")
                    }
                    else if(HeiofCCD!=1){
                        this.$message.warning("线阵模式下,CCD阵列高通常设置为1")
                    }
                    else {
                        if(NumofCCDsX>0 && WidofCCD>0 && this.in_tif_data?.col){
                            let CCD_tif_col=NumofCCDsX*WidofCCD
                            if(CCD_tif_col!=this.in_tif_data?.col){
                                this.$message.warning("线阵模式下,CCD垂轨 * CCD阵列宽 应等于影像的列")
                            }
                        }
                    }
                }
                //面阵
                else if(attribute=="Optical_Frame"){
                    if(NumofCCDsX>0 && WidofCCD>0 && this.in_tif_data?.col){
                        let CCD_tif_col=NumofCCDsX*WidofCCD
                        if(CCD_tif_col!=this.in_tif_data?.col){
                            this.$message.warning("线阵模式下,CCD垂轨 * CCD阵列宽 应等于影像的列")
                        }
                    }
                    else if(NumofCCDsy>0 && HeiofCCD>0 && this.in_tif_data?.row){
                        let CCD_tif_row=NumofCCDsy*HeiofCCD
                        if(CCD_tif_row!=this.in_tif_data?.row){
                            this.$message.warning("面阵模式下,CCD沿轨 * CCD阵列高 应等于影像的行")
                        }
                    }
                }
            }
            else{
                this.sensor_index=-1
                this.in_tif_prop_data.sensor_attribute=""
            }


        },
        select_file(_type){
            let filter=[`.${_type}`]
            let multi=false
            if(_type=="it"){
                multi=true
            }
            this.$mitt.emit('show_modal_select_server_dir', {
                type: _type,
                showfile: true,
                avtive_dir: this.$store.state.task?.data_dir,
                multi:multi,
                showfile_filter: filter,
            },this?.$?.uid);
        },
        select_dir(_type){
            this.$mitt.emit('show_modal_select_server_dir', {
                type: _type,
                showfile: false,
                avtive_dir: this.$store.state.task?.data_dir,
                multi:false,
                showfile_filter: [],
            },this?.$?.uid);
        },
        tab_change(activeKey){
            if(this.sensor_index>=0){
                let sensorInfo=this.$store.state.task.sensors[this.sensor_index].sensorInfo
                let NumofCCDsX=sensorInfo?.NumofCCDs?.x-0 //CCD 数量 垂轨
                let NumofCCDsy=sensorInfo?.NumofCCDs?.y-0 //CCD 数量 沿轨
                let WidofCCD  =sensorInfo?.CCDInfo?.WidofCCD//CCD阵列 宽
                let HeiofCCD  =sensorInfo?.CCDInfo?.HeiofCCD//CCD阵列 高
                let attribute=sensorInfo.attribute
                //判断线阵和面阵的参数 与影像的高宽是否一致
                if(activeKey==3){
                    //CCD数量=垂轨*沿轨
                    let ccd_height=0
                    //线阵+线阵摆扫
                    if(attribute=="Optical_Linear" ||attribute=="Linear_Swing" ){
                        ccd_height=this.in_tif_data?.row
                    }
                    //面阵
                    else if(attribute=="Optical_Frame"){
                        ccd_height=HeiofCCD
                    }
                    if(!this.in_tif_prop_data?.ctl?.ctl_simulate_data || this.in_tif_prop_data?.ctl?.ctl_simulate_data?.length==0){
                        let ctl_simulate_data=[]
                        for (let i = 0; i < NumofCCDsy; i++) {
                            for (let j = 0; j < NumofCCDsX; j++) {
                                let ccd_num=i*NumofCCDsX+j+1;
                                ctl_simulate_data.push({
                                    ccd:`${ccd_num}`,
                                    startX:i*ccd_height,
                                    startY:j*WidofCCD,
                                    width:WidofCCD,
                                    height:ccd_height,
                                    iBand:0,
                                    isSimulate:1,
                                })
                            }
                        }
                        this.in_tif_prop_data.ctl.ctl_simulate_data=ctl_simulate_data
                        console.log("compute _ccd")
                    }
                }
                if(activeKey==3){
                    if(!this.in_tif_prop_data?.ctl_Dom && this.$store.state.last_dom){
                        this.in_tif_prop_data.ctl_Dom=this.$store.state.last_dom
                    }
                    if(!this.in_tif_prop_data?.ctl_Dem && this.$store.state.lst_dem){
                        this.in_tif_prop_data.ctl_Dem=this.$store.state.lst_dem
                    }
                }
            }
        },
        onClose(){
            this.modal_show=false
        },
        async OnSave(){
            this.$Loading.start();
            let update_data={
                task_dir:this.$store.state?.task_dir,
                task_name:this.$store.state.task?.task_name,
                tif_index:this.in_tif_index,
                val:JSON.stringify(this.in_tif_prop_data),
                parmars:JSON.stringify(this.$store.state?.sets)
            }
            if(this.in_tif_prop_data?.ctl_Dom){
                this.$store.state.last_dom=this.in_tif_prop_data?.ctl_Dom
            }
            if(this.in_tif_prop_data?.ctl_Dem){
                this.$store.state.lst_dem=this.in_tif_prop_data?.ctl_Dem
            }
            let update_result=await this.$apis.update_tif_cfg(update_data)
            if(update_result){
                this.$store.state.task.tifs[this.in_tif_index].prop=update_result
                // this.in_tif_prop_data.prop=update_result
                this.$message.success("配置成功")
                this.modal_show=false

            }
            else{
                this.$message.error("更新失败")
            }
            this.$Loading.done();
        }
    },
};
</script>